﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace LibExtend
{
    public partial class LogoutButton : Control
    {
        Rectangle rect = Rectangle.Empty;

        public LogoutButton()
        {
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.ResizeRedraw, true);
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            InitializeComponent();

            rect = new Rectangle(btn.Left, btn.Top, 64, 64);
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            rect = new Rectangle(10, 10, 64, 64);
            e.Graphics.DrawImage(btn.Image, rect);
            //base.OnPaint(e);
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (rect.Contains(e.X, e.Y))
                btn.Visible = true;
            else
                btn.Visible = false;
        }

        protected override void OnResize(EventArgs e)
        {
            if (this.Width != 100) this.Width = 100;
            if (this.Height != 83) this.Height = 83;
            //base.OnResize(e);
        }

        private void btn_Click(object sender, EventArgs e)
        {
            Application.Restart();
        }
    }
}
